<?php
	date_default_timezone_set('Africa/Johannesburg');
	if (isset($_POST['date'], $_POST['id'], $_POST['type'])) {
		
		include '../inc/db.php';
		$cn = new db_mysqli();

		if ($_POST['type'] == 'booking') {
			
			$query = "select *, TIMESTAMPDIFF(MINUTE, start, end) AS mins from bookings where spaceid=".$_POST['id']." and start >= '".$_POST['date']." 00:00' and start <= '".$_POST['date']." 23:59'";
			echo $cn->OutputJSON($query);

		} else if ($_POST['type'] == 'training') {

			$now = date('Y-m-d');
			$query = "select * from training_bookings where date >= $now";
			echo $cn->OutputJSON($query);

		}
	}
?>